﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace WorldOnFire
{
    public class CBlackHole : ABCProjectile
    {
        public override void Initialize(int _nObjectCount)
        {
            // Initialize the base members
            base.Initialize(_nObjectCount);

            // Set the enumerations
            eBaseType[] eBaseTypes = new eBaseType[] { eBaseType.MOVING_OBJECT, eBaseType.PROJECTILE };
            this.SetBaseTypeID(eBaseTypes);

            this.SetObjectType(eObjectType.PROJECTILE_BLACK_HOLE);
            this.SetProjectileID(eProjectileType.BLACK_HOLE);
        }

        public override void Update(float _fDeltaTime)
        {
            // Loop through each black hole
            for( int iBlackHole = 0; iBlackHole < m_nObjectCount; ++iBlackHole )
            {
                // If this object is inactive
                if (m_bObjectActive[iBlackHole] == false)
                {
                    // Skip this object
                    continue;
                }

                // Create a gravitational pull
                SEventSystem.SendEvent(new CEventObjectBlackHole(
                    m_mTransform[iBlackHole].Translation,
                    m_fRadius[iBlackHole],
                    m_fDamage[iBlackHole]));
            }

            // Update the base members
            base.Update(_fDeltaTime);
        }

        protected override void KillProjectile(int _nProjectileIndex)
        {
            // Set the object to inactive
            base.KillProjectile(_nProjectileIndex);

            // Create a large gravitational pull
            SEventSystem.SendEvent(new CEventObjectBlackHole(
                m_mTransform[_nProjectileIndex].Translation,
                2.0f * m_fRadius[_nProjectileIndex],
                5.0f * m_fDamage[_nProjectileIndex]));
        }
    }
}
